<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    .warning{
        background-color:gold;
    }
    .success{
        background-color:rgb(161, 250, 161);
    }
    .moren{
        background-color: white;
    }
    </style>
</head>
<body>
    <div id="app">
        <btn :class-name="btnClass">{{content}}</btn>
        <button @click='clickM'>默认</button>
        <button @click="clickS">成功</button>
        <button @click="clickW">警告</button>
    </div>
    <template id='btn'>
        <div>
            <button :class=[className]><slot></slot></button>
        </div>
    </template>
    <script src="../vue.js"></script>
    <script>
        let btn={
            template:'#btn',
            props: ['className'],
        }
        new Vue({
            el:'#app',
            data () {
                return {
                    content:'默认',
                    btnClass:'',
                    btnList:[
                        {title:'默认',cli:'clickM'},
                        {title:'成功',cli:'clickS'},
                        {title:'警告',cli:'clickW'},
                    ]
                }
            },
            components: {
                btn,
            },
            methods: {
                clickW(){
                    this.btnClass="warning";
                    console.log(this.btnClass);
                    this.content='警告';
                },
                clickS(){
                    this.btnClass="success";
                    console.log(this.btnClass);
                    this.content='成功';
                },
                clickM(){
                    this.btnClass="moren";
                    console.log(this.btnClass);
                    this.content='默认';
                },
            }
        })
    </script>
</body>
</html>